package com.asia5b.a5mall.middleware.logic.viewmodel.order

import androidx.lifecycle.MutableLiveData
import com.asia5b.a5mall.middleware.base.SimpleNetParams
import com.asia5b.a5mall.middleware.base.SimpleViewModel
import com.asia5b.a5mall.middleware.model.base.ResultModel
import com.asia5b.a5mall.middleware.model.order.AftersaleModel
import io.reactivex.functions.Consumer

/**
 * Created by zhangyuncai on 2020/1/13.
 */
class AftersaleActivityVM :SimpleViewModel() {
   private var page = 1
   private var sumPage = 1000

    fun getDatas(refresh: Int) {
        if (refresh <= 1) {
            page = 1
            sumPage = 1000
        }
        if (page > sumPage) {
            dismissLoadingBar()
            return
        }

        val observable = afterSaleApi.getRefundsList(page, 10)

        baseSubscribe(observable, SimpleNetParams(isShowLoading = (refresh==0)),Consumer { resultModel ->
            sumPage = resultModel.sumPage
            page = resultModel.page+1
//            providerView().getDatasResult(resultModel.data)
            getDatasResultLiveData.value=resultModel
        })
    }
    val getDatasResultLiveData= MutableLiveData<ResultModel<ArrayList<AftersaleModel>>>()
}